<template>
  <div class="reportFormPage" v-if="show">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">{{ this.form.baobmc }}</div>
        <div class="codeText">
          <tr v-for="(item, index) in form.baobbhList">
            {{
              item
            }}
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span class="placeholder">{{ form.jilbh }}</span>
        </div>
      </div>
      <!-- .........................1111111111111111111111111111111......................................................... -->
      <div class="table-border">
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>

              <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->
              <td width="35%" class="text-center">
                <el-input v-model="form.shiyjcrq" />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />
                ℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />
                %RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="600px" class="middle-table">
          <tbody>
            <tr trindex="0">
              <td colspan="6" width="100%">
                <div>含泥量试验</div>
              </td>
            </tr>
            <tr trindex="1">
              <td width="10%">
                <div>试验次数</div>
              </td>
              <td width="17%">
                <div>试验前烘干试样质量m<sub>0</sub>（g）</div>
              </td>
              <td width="17%">
                <div>试验后烘干试样质量m<sub>1</sub>（g）</div>
              </td>
              <td width="18%">
                <div>含泥量或小于0.075mm颗粒含量测值Q<sub>n</sub> (%)</div>
              </td>
              <td width="25%" colspan="2">
                <div>含泥量或小于0.075mm颗粒含量测定值Q<sub>n</sub>(%)</div>
              </td>
            </tr>
            <tr trindex="2">
              <td width="15%">
                <div>{{ this.form.hannlSycsItem1 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.hannlsyqhgsyzlItem1"
                  @change="computeHnl(1)"
                  @keydown.native="handleKeyDown($event, 0, 0)"
                  @paste.native="handlePaste($event, 0, 0)"
                  :ref="'0_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.hannlsyhhgsyzlItem1"
                  @change="computeHnl(1)"
                  @keydown.native="handleKeyDown($event, 0, 1)"
                  @paste.native="handlePaste($event, 0, 1)"
                  :ref="'0_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.hannlhxy075klczItem1 }}</div>
              </td>
              <td width="25%" colspan="2" rowspan="2">
                <div>{{ this.form.hannlhxy075klczPjz }}</div>
              </td>
            </tr>
            <tr trindex="3">
              <td width="15%">
                <div>{{ this.form.hannlSycsItem2 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.hannlsyqhgsyzlItem2"
                  @change="computeHnl(2)"
                  @keydown.native="handleKeyDown($event, 1, 0)"
                  @paste.native="handlePaste($event, 1, 0)"
                  :ref="'1_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.hannlsyhhgsyzlItem2"
                  @change="computeHnl(2)"
                  @keydown.native="handleKeyDown($event, 1, 1)"
                  @paste.native="handlePaste($event, 1, 1)"
                  :ref="'1_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.hannlhxy075klczItem2 }}</div>
              </td>
            </tr>
            <tr trindex="4">
              <td colspan="6" width="100%">
                <div>泥块含量试验</div>
              </td>
            </tr>
            <tr trindex="5">
              <td width="15%">
                <div>试验次数</div>
              </td>
              <td width="15%">
                <div>4.75mm筛上试样质量m<sub>2</sub>（g）</div>
              </td>
              <td width="15%">
                <div>试验后烘干试样质量m<sub>3</sub>（g）</div>
              </td>
              <td width="15%">
                <div>泥块含量测值Q<sub>k</sub>(%)</div>
              </td>
              <td width="25%" colspan="2">
                <div>泥块含量测定值Q<sub>k</sub>(%)</div>
              </td>
            </tr>
            <tr trindex="6">
              <td width="15%">
                <div>{{ this.form.nikhlSycsItem1 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.nikhl475sssyzlItem1"
                  @change="computeNkhl(1)"
                  @keydown.native="handleKeyDown($event, 2, 0)"
                  @paste.native="handlePaste($event, 2, 0)"
                  :ref="'2_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.nikhlsyhhgsyzlItem1"
                  @change="computeNkhl(1)"
                  @keydown.native="handleKeyDown($event, 2, 1)"
                  @paste.native="handlePaste($event, 2, 1)"
                  :ref="'2_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.nikhlczItem1 }}</div>
              </td>
              <td width="25%" colspan="2" rowspan="2">
                <div>{{ this.form.nikhlczPjz }}</div>
              </td>
            </tr>
            <tr trindex="7">
              <td width="15%">
                <div>{{ this.form.nikhlSycsItem2 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.nikhl475sssyzlItem2"
                  @change="computeNkhl(2)"
                  @keydown.native="handleKeyDown($event, 3, 0)"
                  @paste.native="handlePaste($event, 3, 0)"
                  :ref="'3_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.nikhlsyhhgsyzlItem2"
                  @change="computeNkhl(2)"
                  @keydown.native="handleKeyDown($event, 3, 1)"
                  @paste.native="handlePaste($event, 3, 1)"
                  :ref="'3_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.nikhlczItem2 }}</div>
              </td>
            </tr>
            <tr trindex="8">
              <td colspan="6" width="100%">
                <div>针片状颗粒含量试验（游标卡尺法）</div>
              </td>
            </tr>
            <tr trindex="9">
              <td width="15%">
                <div>试验次数</div>
              </td>
              <td width="15%">
                <div>非针片状颗粒总质量（g）</div>
              </td>
              <td width="15%">
                <div>针片状颗粒总质量（g）</div>
              </td>
              <td width="15%">
                <div>针片状含量（%）</div>
              </td>
              <td width="25%" colspan="3">
                <div>平均值（%）</div>
              </td>
            </tr>
            <tr trindex="10">
              <td width="15%">
                <div>{{ this.form.zhenpzSycsItem1 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.feizpzklzlItem1"
                  @change="computeZpzhl(1)"
                  @keydown.native="handleKeyDown($event, 4, 0)"
                  @paste.native="handlePaste($event, 4, 0)"
                  :ref="'4_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.zhenpzklzzlItem1"
                  @change="computeZpzhl(1)"
                  @keydown.native="handleKeyDown($event, 4, 1)"
                  @paste.native="handlePaste($event, 4, 1)"
                  :ref="'4_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.zhenpzhlItem1 }}</div>
              </td>
              <td width="25%" colspan="2" rowspan="3">
                <div>{{ this.form.zhenpzsyPjz }}</div>
              </td>
            </tr>
            <tr trindex="11">
              <td width="15%">
                <div>{{ this.form.zhenpzSycsItem2 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.feizpzklzlItem2"
                  @change="computeZpzhl(2)"
                  @keydown.native="handleKeyDown($event, 5, 0)"
                  @paste.native="handlePaste($event, 5, 0)"
                  :ref="'5_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.zhenpzklzzlItem2"
                  @change="computeZpzhl(2)"
                  @keydown.native="handleKeyDown($event, 5, 1)"
                  @paste.native="handlePaste($event, 5, 1)"
                  :ref="'5_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.zhenpzhlItem2 }}</div>
              </td>
            </tr>
            <tr trindex="12">
              <td width="15%">
                <div>{{ this.form.zhenpzSycsItem3 }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.feizpzklzlItem3"
                  @change="computeZpzhl(3)"
                  @keydown.native="handleKeyDown($event, 6, 0)"
                  @paste.native="handlePaste($event, 6, 0)"
                  :ref="'6_0'"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="form.zhenpzklzzlItem3"
                  @change="computeZpzhl(3)"
                  @keydown.native="handleKeyDown($event, 6, 1)"
                  @paste.native="handlePaste($event, 6, 1)"
                  :ref="'6_1'"
                />
              </td>
              <td width="15%">
                <div>{{ this.form.zhenpzhlItem3 }}</div>
              </td>
            </tr>
            <tr trindex="13">
              <td colspan="6" width="100%">
                <div>针片状颗粒含量试验（规准仪法）</div>
              </td>
            </tr>
            <tr trindex="14">
              <td width="10%">
                <div>试样总质量m<sub>0</sub>(g)</div>
              </td>
              <td width="15%">
                <div>粒级(方孔筛)(mm)</div>
              </td>
              <td width="15%">
                <div>针状颗粒质量(g)</div>
              </td>
              <td width="15%">
                <div>片状颗粒质量(g)</div>
              </td>
              <td width="15%">
                <div>针片状颗粒总质量m<sub>1</sub>(g)</div>
              </td>
              <td width="20%">
                <div>针片状颗粒含量测定值Q<sub>e</sub>(%)</div>
              </td>
            </tr>
            <tr v-for="(item, index) in form.detailList">
              <td width="10%" v-if="index == 0" rowspan="6">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.guizyfsyzzl"
                  @change="detailListChange()"
                  @keydown.native="handleKeyDown($event, 7 + index, 0)"
                  :ref="`${7 + index}_0`"
                />
              </td>
              <td width="15%">
                <div>{{ item.guizyfljfks }}</div>
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.guizyfzzklzl"
                  @change="detailListChange()"
                  @keydown.native="handleKeyDown($event, 7 + index, 1)"
                  @paste.native="handlePasteDetailList($event, index, 0)"
                  :ref="`${7 + index}_1`"
                />
              </td>
              <td width="15%">
                <el-input
                  :type="isPdf ? 'string' : 'number'"
                  tabindex="200"
                  v-model="item.guizyfpzklzl"
                  @change="detailListChange()"
                  @keydown.native="handleKeyDown($event, 7 + index, 2)"
                  @paste.native="handlePasteDetailList($event, index, 1)"
                  :ref="`${7 + index}_2`"
                />
              </td>
              <td width="15%" v-if="index == 0" rowspan="6">
                <div>{{ item.guizyfzpzklzzl }}</div>
              </td>
              <td width="15%" v-if="index == 0" rowspan="6">
                <div>{{ item.guizyfzpzklhlcz }}</div>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jiancr}} -->
            </td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left">
              <!-- {{this.form.jilr}} -->
            </td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%">
              <!-- {{this.form.fuhr}} -->
            </td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-right: 30px">年</div>
              <div style="display: inline-block; margin-right: 30px">月</div>
              <div style="display: inline-block">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
  </div>
</template>

<script>
import { handleFocus, emptyConvert, uniqueStr, handleKeyDown, handlePaste } from "@/views/reportForms/utils";
import { getCjlhnlzpzjlbBsInfo } from "@/api/report_jl/cjl";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";

import decimal from "@/utils/big-decimal";
import Bus from "@/utils/bus";

export default {
  name: "cjlhnlzpzjlbTable",
  components: {
    BsInstrumentView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      form: {
        detailList: [],
        baobbhList: []
      },
      backBgz: {},
      show: false,
      showQyxx: false
    };
  },

  computed: {},
  created() {
    this.init();
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    },
    backBgz: {
      handler(newVal, oldVal) {
        this.backBgzFun();
      }
    }
  },
  methods: {
    // 根据报表id获取当前报表信息
    init() {
      this.show = false;
      getCjlhnlzpzjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
        this.setInitialValue();
        this.show = true;
      });
    },
    // 设置初始值
    setInitialValue() {
      if (this.form) {
        this.form.baobmc = this.form.baobmc || "粗集料含泥量、泥块含量、针片状颗粒含量试验检测记录表";
        // this.form.baobmc = "2222粗集料含泥量、泥块含量、针片状颗粒含量试验检测记录表";
        this.form.baobbh = this.form.baobbh || "JGLQ02005,JGLQ02006,JGLQ02007a,JGLQ02007b";
        this.$set(this.form, "baobbhList", []);
        this.form.baobbhList = ["JGLQ02005", "JGLQ02006", "JGLQ02007a", "JGLQ02007b"];
        this.form.hannlSycsItem1 = this.form.hannlSycsItem1 || "1";
        this.form.hannlSycsItem2 = this.form.hannlSycsItem2 || "2";
        this.form.nikhlSycsItem1 = this.form.nikhlSycsItem1 || "1";
        this.form.nikhlSycsItem2 = this.form.nikhlSycsItem2 || "2";
        this.form.zhenpzSycsItem1 = this.form.zhenpzSycsItem1 || "1";
        this.form.zhenpzSycsItem2 = this.form.zhenpzSycsItem2 || "2";
        this.form.zhenpzSycsItem3 = this.form.zhenpzSycsItem3 || "3";
      }
      if (!this.form.detailList || this.form.detailList.length <= 0) {
        this.getDetailList();
      }
    },
    getDetailList() {
      this.$set(this.form, "detailList", []);
      const detail1 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "4.75～9.5",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      const detail2 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "9.5～16.0",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      const detail3 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "16.0～19.0",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      const detail4 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "19.0～26.5",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      const detail5 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "26.5～31.5",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      const detail6 = {
        detailId: null,
        excelId: this.excelId,
        guizyfsyzzl: null,
        guizyfljfks: "31.5～37.5",
        guizyfzzklzl: null,
        guizyfpzklzl: null,
        guizyfzpzklzzl: null,
        guizyfzpzklhlcz: null
      };
      this.form.detailList.push(detail1);
      this.form.detailList.push(detail2);
      this.form.detailList.push(detail3);
      this.form.detailList.push(detail4);
      this.form.detailList.push(detail5);
      this.form.detailList.push(detail6);
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setCjlBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setCjlBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 返回报告引入值
    backBgzFun() {
      // this.$emit("backBgzFun", this.backBgz);
      Bus.$emit("setCjlBgJiancjg", [
        { key: 12, value: this.form.detailList[0].guizyfzpzklhlcz || this.form.zhenpzsyPjz }, // 针片状颗粒含量
        { key: 20, value: this.form.hannlhxy075klczPjz },
        { key: 34, value: this.form.hannlhxy075klczPjz },
        { key: 28, value: this.form.nikhlczPjz }
      ]);
    },
    detailListChange() {
      const newVal = this.form.detailList;
      if (newVal) {
        let e,
          f,
          h = null,
          g = 0;
        for (let i = 0; i < newVal.length; i++) {
          if (newVal[i]) {
            if (newVal[i].guizyfzzklzl || newVal[i].guizyfpzklzl) {
              e = decimal.add(e, newVal[i].guizyfzzklzl);
              f = decimal.add(f, newVal[i].guizyfpzklzl);
              h = decimal.add(e, f, 1);
            }
            g = newVal[0].guizyfsyzzl;
          }
        }
        if (newVal[0]) {
          newVal[1].guizyfsyzzl = g;
          newVal[2].guizyfsyzzl = g;
          newVal[3].guizyfsyzzl = g;
          newVal[4].guizyfsyzzl = g;
          newVal[5].guizyfsyzzl = g;
        }

        for (let i = 0; i < newVal.length; i++) {
          if (newVal[i]) {
            newVal[i].guizyfzpzklzzl = h;
            if (g && g != 0) {
              const a = decimal.multiply(100, h);
              const b = decimal.divide(a, g, 1);
              newVal[i].guizyfzpzklhlcz = b;
              // this.$set(this.backBgz, "guizyfzpzklhlcz", newVal[i].guizyfzpzklhlcz);
            } else {
              newVal[i].guizyfzpzklhlcz = null;
              // this.$set(this.backBgz, "guizyfzpzklhlcz", newVal[i].guizyfzpzklhlcz);
            }
          }
        }
        this.backBgzFun();
      }
    },
    submitForm() {
      return this.form;
    },
    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    // 含泥量试验1
    computeHnl(index) {
      const hannlsyqhgsyzlItem = this.form["hannlsyqhgsyzlItem" + index];
      const hannlsyhhgsyzlItem = this.form["hannlsyhhgsyzlItem" + index];
      if (hannlsyqhgsyzlItem && hannlsyqhgsyzlItem != 0) {
        const a = decimal.subtract(hannlsyqhgsyzlItem, hannlsyhhgsyzlItem || 0);
        const b = decimal.multiply(100, a);
        const c = decimal.divide(b, hannlsyqhgsyzlItem, 1);
        this.form["hannlhxy075klczItem" + index] = c;
      } else {
        this.form["hannlhxy075klczItem" + index] = null;
      }
      this.computeHannlhxy075klczPjz();
    },
    // 计算含泥量试验平均值
    computeHannlhxy075klczPjz() {
      if (this.form.hannlhxy075klczItem1 && this.form.hannlhxy075klczItem2) {
        const d = decimal.add(this.form.hannlhxy075klczItem1 || 0, this.form.hannlhxy075klczItem2 || 0);
        const e = decimal.divide(d, 2, 1);
        this.form.hannlhxy075klczPjz = e;
      } else {
        this.form.hannlhxy075klczPjz = null;
      }
      this.backBgzFun();
      // this.$set(this.backBgz, "hannlhxy075klczPjz", this.form.hannlhxy075klczPjz);
    },
    // 泥块含量试验1
    computeNkhl(index) {
      const nikhl475sssyzlItem = this.form["nikhl475sssyzlItem" + index];
      const nikhlsyhhgsyzlItem = this.form["nikhlsyhhgsyzlItem" + index];
      if (nikhl475sssyzlItem && nikhl475sssyzlItem != 0) {
        const a = decimal.subtract(nikhl475sssyzlItem, nikhlsyhhgsyzlItem || 0);
        const b = decimal.multiply(100, a);
        const c = decimal.divide(b, nikhl475sssyzlItem, 1);
        this.form["nikhlczItem" + index] = c;
      } else {
        this.form["nikhlczItem" + index] = null;
      }
      this.computeNikhlczPjz();
    },
    // 泥块含量试验平均值
    computeNikhlczPjz() {
      if (this.form.nikhlczItem1 && this.form.nikhlczItem2) {
        const d = decimal.add(this.form.nikhlczItem1 || 0, this.form.nikhlczItem2 || 0);
        const e = decimal.divide(d, 2, 1);
        this.form.nikhlczPjz = e;
      } else {
        this.form.nikhlczPjz = null;
      }
      this.backBgzFun();
      // this.$set(this.backBgz, "nikhlczPjz", this.form.nikhlczPjz);
    },
    // 针片状颗粒含量试验游标卡尺1
    computeZpzhl(index) {
      const zhenpzklzzlItem = this.form["zhenpzklzzlItem" + index];
      const nikhlsyhhgsyzlItem = this.form["nikhlsyhhgsyzlItem" + index];
      if (!zhenpzklzzlItem || !nikhlsyhhgsyzlItem) {
        this.form["zhenpzhlItem" + index] = null;
        this.computeZhenpzsyPjz();
        return;
      }
      const a = decimal.multiply(100, zhenpzklzzlItem || 0);
      const b = decimal.add(nikhlsyhhgsyzlItem || 0, zhenpzklzzlItem || 0, 1);
      if (b != 0) {
        const c = decimal.divide(a, b);
        this.form["zhenpzhlItem" + index] = c;
      } else {
        this.form["zhenpzhlItem" + index] = null;
      }
      this.computeZhenpzsyPjz();
    },
    // 针片状颗粒含量试验游标卡尺平均值
    computeZhenpzsyPjz() {
      if (this.form.zhenpzhlItem1 && this.form.zhenpzhlItem2) {
        const d = decimal.add(this.form.zhenpzhlItem1 || 0, this.form.zhenpzhlItem2 || 0);
        const e = decimal.divide(d, 2, 1);
        this.form.zhenpzsyPjz = e;
      } else {
        this.form.zhenpzsyPjz = null;
      }
      this.backBgzFun();
      // this.$set(this.backBgz, "zhenpzsyPjz", this.form.zhenpzsyPjz);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2]; // 每一行最多有多少可聚焦输入框（从0开始）
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      // 通过_拆分字符串
      const arr = ref.split("_");
      if (arr[0] >= 7) {
        if (arr[0] > 7 && arr[1] == 0) {
          this.handleKeyDown(event, arr[0], arr[1]);
          return;
        }
        if (this.$refs[ref][0]) {
          this.$refs[ref][0].focus();
        }
      } else if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    },
    // 粘贴赋值方法
    handlePaste(event, rowIndex, colIndex) {
      const nameAllArr = [
        ["hannlsyqhgsyzlItem1", "hannlsyhhgsyzlItem1"],
        ["hannlsyqhgsyzlItem2", "hannlsyhhgsyzlItem2"],
        ["nikhl475sssyzlItem1", "nikhlsyhhgsyzlItem1"],
        ["nikhl475sssyzlItem2", "nikhlsyhhgsyzlItem2"],
        ["feizpzklzlItem1", "zhenpzklzzlItem1"],
        ["feizpzklzlItem2", "zhenpzklzzlItem2"],
        ["feizpzklzlItem3", "zhenpzklzzlItem3"]
      ];
      const subscriptArr = [
        [0, 1],
        [0, 1],
        [0, 1],
        [0, 1],
        [0, 1],
        [0, 1],
        [0, 1]
      ];

      const methodsAllArr = [
        ["computeHnl", "computeHnl"],
        ["computeHnl", "computeHnl"],
        ["computeNkhl", "computeNkhl"],
        ["computeNkhl", "computeNkhl"],
        ["computeZpzhl", "computeZpzhl"],
        ["computeZpzhl", "computeZpzhl"],
        ["computeZpzhl", "computeZpzhl"]
      ];
      const parameterArr = [
        [1, 1],
        [2, 2],
        [1, 1],
        [2, 2],
        [1, 1],
        [2, 2],
        [3, 3]
      ];
      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form[nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // detailList粘贴赋值方法
    handlePasteDetailList(event, rowIndex, colIndex) {
      const nameAllArr = this.form.detailList.map((item, index) => {
        return ["guizyfzzklzl", "guizyfpzklzl"];
      });
      const subscriptArr = this.form.detailList.map((item, index) => {
        return [0, 1];
      });
      const methodsAllArr = this.form.detailList.map((item, index) => {
        return ["detailListChange", "detailListChange"];
      });
      const parameterArr = this.form.detailList.map((item, index) => {
        return [null, null];
      });

      const data = handlePaste(event, rowIndex, colIndex, nameAllArr, methodsAllArr, parameterArr, subscriptArr);
      const { cols, nameSetArr, methodsSetArr, parameterSetArr, subscriptSetArr } = data;
      for (let a = 0; a < nameSetArr.length; a++) {
        for (let b = 0; b < nameSetArr[a].length; b++) {
          this.form.detailList[rowIndex + a][nameSetArr[a][b]] = cols[a][b];
        }
      }
      for (let a = 0; a < methodsSetArr.length; a++) {
        for (let b = 0; b < methodsSetArr[a].length; b++) {
          if (methodsSetArr[a][b]) {
            this.setCalculate(methodsSetArr[a][b], parameterSetArr[a][b]);
          }
        }
      }
    },

    // 计算方法调用
    setCalculate(name, a, b, c, d, e) {
      this[name](a, b, c, d, e);
    }
  }
};
</script>

<style scoped lang="scss"></style>
